package main;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import java.util.Stack;


public class Staff {

	private int verticalOffset;
	private int horizontalOffset;
	private Area symbol;

	public Staff(int hOff, int vOff){
		horizontalOffset = hOff;
		verticalOffset = vOff;
		generateSymbol();
	}
	

	/**
	 * Creates the bar lines
	 */
	private void generateSymbol() {
		Stack<Area> lines = new Stack<Area>();
		for(int i = 4; i >= 0; i--){
			Rectangle2D.Double temp = new Rectangle2D.Double(0, i*(Score.BAR_LINE_WIDTH+Score.BAR_LINE_SPACING), Score.BAR_LINE_LENGTH, Score.BAR_LINE_WIDTH);
			Area a = new Area(temp);
			lines.push(a);
		} //now have a stack of the 5 barlines with the top barline at the top of the stack

		symbol = lines.pop();
		while(!lines.isEmpty()){
			Area temp = lines.pop();
			symbol.add(temp);
		}
	}
	
	/**
	 * draws the barlines
	 * @param g graphics context
	 */
	public void draw(Graphics2D g){
		g.fill(symbol);
	}
	
	/**
	 * 
	 * @return transform on the barlines
	 */
	public AffineTransform getTransform(){
		return AffineTransform.getTranslateInstance(horizontalOffset, verticalOffset);
	}


	/**
	 * 
	 * @return vertical offset of the barlines
	 */
	public int getVerticalOffset() {
		return verticalOffset;
	}
}
